package cn.wizzer.app.crown.commons.websocket.action.hg;

import cn.wizzer.app.crown.commons.websocket.main.action.BaseNettyAction;
import cn.wizzer.app.crown.commons.websocket.main.action.NettyAction;
import cn.wizzer.app.crown.commons.websocket.main.base.NettyRouter;
import cn.wizzer.app.crown.modules.services.CrownMatchService;
import cn.wizzer.framework.util.Result;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.log.Log;
import org.nutz.log.Logs;

import java.util.Map;

/**
 * 综合推送
 */
@IocBean
@NettyAction(uri = "/hg/match/complex")
public class ComplexPlayWayAction extends BaseNettyAction {

    public static BaseNettyAction instance() {
        return BaseNettyAction.instance(ComplexPlayWayAction.class);
    }

    private static final Log log = Logs.get();

    @Inject
    private CrownMatchService matchService;


    @Override
    public Result action(Map<String, String> params) {
        return Result.error();
    }

    @Override
    public Result subscribe(NettyRouter router) {
        // 订阅时，如果订阅数量为0，立刻执行爬取所有玩法并推送。当有多个人订阅，订阅数量大于0，所有玩法会在列表程序中爬取。
        if (this.countSubscribe(router.getParams().get("subscribe")) == 1) {
//            CrownMatch crownMatch = matchService.crawlerAllBets(router.getParams());
//            TextWebSocketFrameHandler.send(router.getIncome(), crownMatch, "/hg/match/complex:" + crownMatch.getId());
        }
        return Result.success();
    }
}
